package com.acme.bankapp.service.bank;

import java.io.FileNotFoundException;
import java.io.IOException;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.CheckingAccount;
import com.acme.bankapp.domain.bank.Client;
import com.acme.bankapp.domain.bank.Gender;
import com.acme.bankapp.domain.bank.SavingAccount;
import com.acme.bankapp.domain.exceptions.ClientExistsException;
import com.acme.bankapp.domain.exceptions.NotEnoughFundsException;
import com.acme.bankapp.domain.exceptions.OverDraftLimitExceededException;

public class BankApplication {	
	
	public static void modifyBank(Bank bank) {
		try{
			Client bank_client1, bank_client2;
			bank_client1 = bank.getClient(0);
			bank_client2 = bank.getClient(1);			
			bank_client1.getAccount(0).withdraw(1250);
			bank_client2.getAccount(0).deposit(345);
		}
		catch (IllegalArgumentException e) {
			System.out.println("The Exception" + e.getMessage() + " has occured");
		}
		catch (OverDraftLimitExceededException e) {
			System.out.println("The Exception OverDraftLimitExceededException has occured");
			System.out.println("request exceeded balance on " + e.getAmount());
		} catch (NotEnoughFundsException e) {			
			System.out.println(e.getMessage());
		}
	}

	
	public static void main(String[] args) {
		
		if(args.length < 2) {
			System.out.println("the wrong input data");
			return;
		}
		if (!args[0].equals("-loadfeed")) {
			System.out.println("not a -loadfeed");
			return;
		}
				
		Bank SberBank = new Bank();
		try {
			BankDataLoaderService bs = new BankDataLoaderService(SberBank, args[1]);
			bs.bankLoad();
		}
		catch (FileNotFoundException e) {
			System.out.println("feedfile does not exists");
			return;
		} catch (IOException e) {
			System.out.println("IOexception");
		}		
	}

}
